package com.kun.valiant.follow.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.kun.valiant.follow.domain.FollowRecord;
import com.kun.valiant.follow.mapper.FollowRecordMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kun.valiant.common.constant.ValiantConstants;
import com.kun.valiant.common.core.domain.AjaxResult;
import com.kun.valiant.follow.service.IFollowRecordService;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fangkun
 * @since 2023-06-08
 */
@Service
public class FollowRecordServiceImpl extends ServiceImpl<FollowRecordMapper, FollowRecord> implements IFollowRecordService {

    @Override
    public AjaxResult getFollowRecordByClueId(Long clueId) {
        LambdaQueryWrapper<FollowRecord> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(FollowRecord::getType, ValiantConstants.CLUE_TYPE)
                .eq(FollowRecord::getAssignId,clueId)
                .orderByDesc(FollowRecord::getCreateTime);
        return AjaxResult.success(list(queryWrapper));
    }

    @Override
    public AjaxResult getBusinessRecordById(Long businessId) {
        LambdaQueryWrapper<FollowRecord> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(FollowRecord::getType, ValiantConstants.BUSINESS_TYPE)
                .eq(FollowRecord::getAssignId,businessId)
                .orderByDesc(FollowRecord::getCreateTime);
        return AjaxResult.success(list(queryWrapper));
    }
}
